package com.tingyuge.thinking.spring.dependency.injection;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;

/**
 * autowiring 依赖 setter 方法注入
 * @author xiaodao
 * @version 1.0
 * @date 2021/6/29
 */
public class AutowiringByNameDependencySetterInjectionDemo {

    public static void main(String[] args) {
        DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();

        XmlBeanDefinitionReader beanDefinitionReader = new XmlBeanDefinitionReader(beanFactory);
        String xmlClassPath = "classpath:/META-INF/autowiring-dependency-setter-context.xml";
        beanDefinitionReader.loadBeanDefinitions(xmlClassPath);
        //加载xml 资源 解析并生成BeanDefinition
        UserHolder bean = beanFactory.getBean(UserHolder.class);
        System.out.println(bean);
    }
}
